package cn.sxt.userscenter.head.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.sxt.usercenter.common.util.ConstatFinalUtil;
import cn.sxt.usercenter.common.util.PageInfoUtil;
import cn.sxt.userscenter.users.pojo.AAdmins;
import cn.sxt.userscenter.users.service.IUsersService;

/**
 * 不需要登陆的操作
 */
@Controller
public class NoLoginController {

	@Resource
	private IUsersService usersService;

	@RequestMapping("/adminsList")
	public String adminsList(HttpServletRequest request){
		ConstatFinalUtil.LOGGER.info("----adminsList--");
		
		PageInfoUtil pageInfoUtil = new PageInfoUtil() ; 
		/* 按照id查询 */
		Map<String, Object> condMap = new HashMap<String,Object>();
		List<AAdmins> adminsList = this.usersService.findCondListAdminsService(pageInfoUtil, condMap);
		/* 存储结果 */
		request.setAttribute("adminsList", adminsList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		return "/head/adminsList";
	}
	
	/*打开登陆页面*/
	@RequestMapping("/login")
	public String login(){
		ConstatFinalUtil.LOGGER.info("----login---");
		return "/head/login";
	}
	/*打开登陆页面*/
	@RequestMapping("/loginSubmit")
	public String loginSubmit(String id){
		ConstatFinalUtil.LOGGER.info("----loginSubmit---");
		/*模拟登陆成功*/
		if("1".equalsIgnoreCase(id)){
			return "reditect:/head/users/main.htm";
		}
		return this.login();
	}
}
